package com.xiashuxia.orgims.interceptor;

import java.util.Map;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class LoginInterceptor extends AbstractInterceptor{

	private static final long serialVersionUID = 1427674000258667496L;

	@Override
	public String intercept(ActionInvocation actionInvocation) throws Exception {
		Map<?, ?> session = actionInvocation.getInvocationContext().getSession();
		String username = (String) session.get("user");
				
		if (username != null && username.length() > 0) {
			return actionInvocation.invoke();
		} else {
			ActionContext actionContext = actionInvocation.getInvocationContext();
			actionContext.put("popedom", "您还没有登陆，请登陆");
			return Action.LOGIN;
		}
	}

}
